#include "mythread.h"
#include <thread>
#include <QDebug>
#include <iostream>
#include <string>
#include <iosfwd>
#include <sstream>

using namespace std;

MyThread::MyThread(QObject *parent) : QObject(parent)
{
    
}

void MyThread::start()
{
    std::thread th(&MyThread::deal,this);
    th.detach();
}

void MyThread::deal()
{
    while(1){
        char buf[32] = {0};
        stringstream sin;
        sin << this_thread::get_id();
        string str = sin.str();
        sprintf(buf,"id:%d  thread id:%s",id,str.c_str());
        emit text(buf);
        this_thread::sleep_for(chrono::seconds(1));
    }
    
}
